From: Matthias Clasen Date: Wed, 1 Dec 2021 02:42:19 +0000 (-0500) Subject: textbuffer: Try harder to fix pasting X-Git-Tag: archive/raspbian/4.6.5+ds-1+rpi1~1^2~91^2^2~104^2 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=3e7618fef7858fe90dfffee9db951d30009dedf8;p=gtk4.git textbuffer: Try harder to fix pasting It turns out we can't just use the size returned by the memory stream as-is, since it may contain unfilled garbage at the end, which utf8 validation will choke on. So, cut it off at the first '\0' we find. --- diff --git a/gtk/gtktextbuffer.c b/gtk/gtktextbuffer.c index a99b25a940..c2cd148868 100644 --- a/gtk/gtktextbuffer.c +++ b/gtk/gtktextbuffer.c @@ -327,6 +327,8 @@ gtk_text_buffer_deserialize_text_plain_finish (GObject *source, if (data) { + if (memchr (data, '\0', size)) + size = -1; buffer = g_value_get_object (gdk_content_deserializer_get_value (deserializer)); gtk_text_buffer_get_end_iter (buffer, &end); gtk_text_buffer_insert (buffer, &end, data, size);